<template>
	<view>
		<button @click="islogin">是否登录</button>
		<button @click="logindata">登录信息</button>
		<!-- <button @click="login">清除登录</button> -->

		<button @click="login">登录</button>
		<button @click="loginout">清除登录</button>
		<button @click="getreq">get请求</button>
		<button @click="postreq">post请求</button>

		<drag-button :isDock="true" :existTabBar="true"   :toppading="true" />
	</view>
</template>

<script>
	export default {
		methods: {
			islogin() {
				var self = this;
				this.$lobster.event.sendEvent("islogin", {}, res => {
					uni.showModal({
						title: "islogin",
						content: JSON.stringify(res),
					})
				})
			},
			logindata() {
				var self = this;
				this.$lobster.event.sendEvent("logindata", {}, res => {
					uni.showModal({
						title: "logindata",
						content: JSON.stringify(res),
					})
				})
			},

			login() {
				var json ='{"UserId":"1612774366","ssotoken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VyVHlwZSI6IjEiLCJVc2VyTmFtZSI6IueUmOeUmCIsIklzQWRtaW4iOiItMSIsIkRlcHRJZCI6Ijk5OTk5IiwiRW1wSWQiOiI5OTk5OSIsIkVtcE5hbWUiOiLlvq7kv6EiLCJTU09Vc2VySWQiOiIyMDUyIiwiVXNlcklkIjoiMTYxMjc3NDM2NiIsIldvcmtJZCI6IjIwNDkiLCJHdWlkIjoiZmJlYmIxM2NjODA5NDUzNGEyN2FjM2MzMWRiNmNjMDciLCJSb290V29ya0lkIjoiMCIsIm5iZiI6MTY0ODcwNzE3NywiZXhwIjoxNjQ5MzEyMDk3LCJpc3MiOiJrYWtha2UiLCJhdWQiOiJldmVyeW9uZSJ9.Vz7zdrv7hdbO05p6HyXaGTmYKKva5QryVRZwxzmuu8M","OpenId":""}';
				var data =JSON.parse(json);
				uni.setStorageSync('hasLogin', true);
				uni.setStorageSync('userId', data.UserId);
				uni.setStorageSync('ssoToken', data.ssotoken);
				uni.setStorageSync('openId', data.OpenId);
				// return;
				// this.$lobster.event.sendEvent("logindata", {}, res => { 
				// 	var data = res.data;
				// 	uni.setStorageSync('hasLogin', true);
				// 	uni.setStorageSync('userId', data.UserId);
				// 	uni.setStorageSync('ssoToken', data.ssotoken);
				// 	uni.setStorageSync('openId', data.OpenId); 
				// })
			},
			loginout() {
				uni.setStorageSync('hasLogin', false);
				uni.setStorageSync('userId', "");
				uni.setStorageSync('ssoToken', "");
				uni.setStorageSync('openId', "");
			},
			//get请求
			getreq() {
				this.$lobster.http.get("https://xinleapi2.mcloudsoft.cn/self-patient/v1/VideoMedical/GetFrequencyData", {
					workId: 2049,
					//userId: uni.getStorageSync('userId'),
				}).then(res => {
					uni.showModal({
						title: "测试",
						content: JSON.stringify(res)
					})
				}).catch(res => {
					uni.showModal({
						title: "测试22222",
						content: JSON.stringify(res)
					})
				});
			},
			//post 请求
			postreq() {
				this.$lobster.http.post("https://xinleapi2.mcloudsoft.cn/self-patient/v1/Order/MultAccountImport", {
						workId: 2049, 
						doctorIdeintifier:"user1",
						userIdentifier:"user2",
					}).then(res => {
						uni.showModal({
							title: "测试",
							content: JSON.stringify(res)
						})
					}).catch(res => {
						uni.showModal({
							title: "测试22222",
							content: JSON.stringify(res)
						})
					}); 
			}
		},
		onLoad() {

		},
	}
</script>

<style>
</style>
